import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/newsregister',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/newsregister',
      component: () => import('@/views/login/register'),
      meta: {title: '注册', icon: 'el-icon-house'}
    }]
  },
  {
    path: '/newslogin',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/newslogin',
      component: () => import('@/views/login/index'),
      meta: {title: '登录', icon: 'el-icon-house'}
    }]
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/index',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/index',
      component: () => import('@/views/index/index'),
      meta: {title: '首页', icon: 'el-icon-house'}
    }]
  },
  {
    path: '/newsview',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/newsview',
      component: () => import('@/views/news/view'),
      meta: {title: '预览', icon: 'el-icon-house'}
    }]
  },
  {
    path: '/news',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news',
      component: () => import('@/views/news/index'),
      meta: {title: '通知公告', icon: 'el-icon-house'}
    }]
  },
  {
    path: '/news2',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news2',
      component: () => import('@/views/news/hangye'),
      meta: {title: '行业动态', icon: 'el-icon-house'}
    }]
  },
  {
    path: '/news3',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news3',
      component: () => import('@/views/news/dangjian'),
      meta: {title: '党建工作', icon: 'el-icon-house'}
    }]
  },

  {
    path: '/news4',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news4',
      component: () => import('@/views/news/yuanshi'),
      meta: {title: '院士大师'}
    }]
  },
  {
    path: '/news5',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news5',
      component: () => import('@/views/news/fenzhi'),
      meta: {title: '分支机构'}
    }]
  },
  {
    path: '/news6',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news6',
      component: () => import('@/views/news/about'),
      meta: {title: '关于协会'}
    }]
  },
  {
    path: '/news7',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news7',
      component: () => import('@/views/news/huiyuan'),
      meta: {title: '会员展示'}
    }]
  },
  {
    path: '/news8',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news8',
      component: () => import('@/views/news/hxinwen'),
      meta: {title: '会员新闻'}
    }]
  },
  {
    path: '/news9',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news9',
      component: () => import('@/views/news/huiyuanview'),
      meta: {title: '会员详情'}
    }]
  },
  {
    path: '/news10',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news10',
      component: () => import('@/views/news/download'),
      meta: {title: '附件下载'}
    }]
  },

  // mmmmm

  {
    path: '/newsregister_m',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/newsregister_m',
      component: () => import('@/views/login/register_m'),
      meta: {title: '注册', icon: 'el-icon-house'}
    }]
  },
  {
    path: '/newslogin_m',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/newslogin_m',
      component: () => import('@/views/login/index_m'),
      meta: {title: '登录', icon: 'el-icon-house'}
    }]
  },
  {
    path: '/index_m',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/index_m',
      component: () => import('@/views/index/index_m'),
      meta: {title: '首页', icon: 'el-icon-house'}
    }]
  },
  {
    path: '/newsview_m',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/newsview_m',
      component: () => import('@/views/news/view_m'),
      meta: {title: '预览', icon: 'el-icon-house'}
    }]
  },
  {
    path: '/news_m',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news_m',
      component: () => import('@/views/news/index_m'),
      meta: {title: '通知公告', icon: 'el-icon-house'}
    }]
  },
  {
    path: '/news2_m',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news2_m',
      component: () => import('@/views/news/hangye_m'),
      meta: {title: '行业动态', icon: 'el-icon-house'}
    }]
  },

  {
    path: '/news3_m',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news3_m',
      component: () => import('@/views/news/dangjian_m'),
      meta: {title: '党建工作', icon: 'el-icon-house'}
    }]
  },

  {
    path: '/news4_m',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news4_m',
      component: () => import('@/views/news/yuanshi_m'),
      meta: {title: '院士大师'}
    }]
  },
  {
    path: '/news5_m',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news5_m',
      component: () => import('@/views/news/fenzhi_m'),
      meta: {title: '分支机构'}
    }]
  },
  {
    path: '/news6_m',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news6_m',
      component: () => import('@/views/news/about_m'),
      meta: {title: '关于协会'}
    }]
  },
  {
    path: '/news7_m',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news7_m',
      component: () => import('@/views/news/huiyuan_m'),
      meta: {title: '会员展示'}
    }]
  },
  {
    path: '/news8_m',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news8_m',
      component: () => import('@/views/news/hxinwen_m'),
      meta: {title: '会员新闻'}
    }]
  },
  {
    path: '/news9_m',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news9_m',
      component: () => import('@/views/news/huiyuanview_m'),
      meta: {title: '会员详情'}
    }]
  },
  {
    path: '/news10_m',
    component: Layout,
    redirect: 'noRedirect',
    hidden: true,
    children: [{
      path: '/news10_m',
      component: () => import('@/views/news/download_m'),
      meta: {title: '附件下载'}
    }]
  },
]

const createRouter = () => new Router({
  mode: 'history', // require service support
  scrollBehavior: () => ({y: 0}),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
